package com.duothread;

public class Demo2 {
    public static void main(String[] args) {
        // 创建线程类对象
        Thread thread1 = new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 10; i++) {
                    System.out.println(Thread.currentThread().getName() + "---" + i);
                }
            }
        }, "线程1");

        Thread thread2 = new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 1; i < 6; i++) {
                    System.out.println(Thread.currentThread().getName() + "：" + i);
                }
            }
        }, "线程2");
        // 启动线程
        thread1.start();
        thread2.start();
    }
}